from django.shortcuts import render

# Create your views here.
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import base64
import io

def draw_bar(request):
    x = [1, 2, 3]
    y = [4, 5, 6]
    plt.plot(x, y)
    img = io.BytesIO()
    plt.savefig(img, format='png')

    print(img.seek(0))
    plot_url = base64.b64encode(img.getvalue()).decode()
    # print("plot_url=",plot_url)
    args = {
        "plot_url":plot_url
    }
    return render(request,'draw_bar.html',args)